﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GA.Shared.Interfaces;
using System.Windows;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Windows.Data;
using GA.Server.DatabaseManager;
using GA.Shared.Objects;

namespace GA.Server.Objects
{
    public class DatabaseAgency : DatabaseObject
    {
        /// <summary>
        /// Identifies the Id Property.
        /// </summary>
        public static readonly DependencyProperty IdProperty =
            DependencyProperty.Register(
                "Id",
                typeof(int),
                typeof(DatabaseAgency),
                new PropertyMetadata(-1));

        /// <summary>
        /// Idenfities the GameId Property.
        /// </summary>
        public static readonly DependencyProperty GameIdProperty =
            DependencyProperty.Register(
                "GameId",
                typeof(int),
                typeof(DatabaseAgency),
                new PropertyMetadata(-1));

        /// <summary>
        /// Identifies the Name Property.
        /// </summary>
        public static readonly DependencyProperty NameProperty =
            DependencyProperty.Register(
                "Name",
                typeof(string),
                typeof(DatabaseAgency),
                new PropertyMetadata(string.Empty));

        /// <summary>
        /// Identifies the LeaderId Property.
        /// </summary>
        public static readonly DependencyProperty LeaderIdProperty =
            DependencyProperty.Register(
                "LeaderId",
                typeof(int),
                typeof(DatabaseAgency),
                new PropertyMetadata(string.Empty));

        /// <summary>
        /// Identifies the Leader Property.
        /// </summary>
        public static readonly DependencyProperty LeaderProperty =
            DependencyProperty.Register(
                "Leader",
                typeof(User),
                typeof(DatabaseAgency),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the OwnedHexes Property.
        /// </summary>
        public static readonly DependencyProperty OwnedHexesProperty =
            DependencyProperty.Register(
                "OwnedHexes",
                typeof(ObservableCollection<Hex>),
                typeof(DatabaseAgency),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the Currency Property.
        /// </summary>
        public static readonly DependencyProperty CurrencyProperty =
            DependencyProperty.Register(
                "Currency",
                typeof(int),
                typeof(DatabaseAgency),
                new PropertyMetadata(0));

        /// <summary>
        /// Identifies the Items Property.
        /// </summary>
        public static readonly DependencyProperty ItemsProperty =
            DependencyProperty.Register(
                "Items",
                typeof(ObservableCollection<Item>),
                typeof(DatabaseAgency),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the AllianceId Property.
        /// </summary>
        public static readonly DependencyProperty AllianceIdProperty =
            DependencyProperty.Register(
                "AllianceId",
                typeof(int?),
                typeof(DatabaseAgency),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the Alliance Property.
        /// </summary>
        public static readonly DependencyProperty AllianceProperty =
            DependencyProperty.Register(
                "Alliance",
                typeof(Alliance),
                typeof(DatabaseAgency),
                new PropertyMetadata(null));

        /// <summary>
        /// Idenfities the Members Property.
        /// </summary>
        public static readonly DependencyProperty MembersProperty =
            DependencyProperty.Register(
                "Members",
                typeof(ObservableCollection<User>),
                typeof(DatabaseAgency),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the MemberRequests Property.
        /// </summary>
        public static readonly DependencyProperty MemberRequestsProperty =
            DependencyProperty.Register(
                "MemberRequests",
                typeof(ObservableCollection<User>),
                typeof(DatabaseAgency),
                new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets the Id.
        /// </summary>
        
        [DatabaseField("Id", IsIdentity = true, IsKey = true)]
        public int Id
        {
            get { return (int)SafeGetValue(IdProperty); }
            set { SafeSetValue(IdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the GameId.
        /// </summary>
        
        [DatabaseField("GameId", IsKey = true)]
        public int GameId
        {
            get { return (int)SafeGetValue(GameIdProperty); }
            set { SafeSetValue(GameIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Name.
        /// </summary>
        
        [DatabaseField("Name", IsKey = true, IsQuoted = true)]
        public string Name
        {
            get { return (string)SafeGetValue(NameProperty); }
            set { SafeSetValue(NameProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Leader Id.
        /// </summary>
        
        [DatabaseField("LeaderId")]
        public int LeaderId
        {
            get { return (int)SafeGetValue(LeaderIdProperty); }
            set { SafeSetValue(LeaderIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Leader.
        /// </summary>
        
        public Player Leader
        {
            get { return (Player)SafeGetValue(LeaderProperty); }
            set { SafeSetValue(LeaderProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Hexes.
        /// </summary>
        
        public ObservableCollection<Hex> OwnedHexes
        {
            get { return (ObservableCollection<Hex>)SafeGetValue(OwnedHexesProperty); }
            set { SafeSetValue(OwnedHexesProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Currency.
        /// </summary>
        
        [DatabaseField("Currency")]
        public int Currency
        {
            get { return (int)SafeGetValue(CurrencyProperty); }
            set { SafeSetValue(CurrencyProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Items.
        /// </summary>
        
        public ObservableCollection<Item> Items
        {
            get { return (ObservableCollection<Item>)SafeGetValue(ItemsProperty); }
            set { SafeSetValue(ItemsProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Alliance Id.
        /// </summary>
        
        [DatabaseField("AllianceId")]
        public int? AllianceId
        {
            get { return (int?)SafeGetValue(AllianceIdProperty); }
            set { SafeSetValue(AllianceIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Alliance.
        /// </summary>
        
        public Alliance Alliance
        {
            get { return (Alliance)SafeGetValue(AllianceProperty); }
            set { SafeSetValue(AllianceProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Members.
        /// </summary>
        
        public ObservableCollection<User> Members
        {
            get { return (ObservableCollection<User>)SafeGetValue(MembersProperty); }
            set { SafeSetValue(MembersProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Member Requests.
        /// </summary>
        
        public ObservableCollection<User> MemberRequests
        {
            get { return (ObservableCollection<User>)SafeGetValue(MemberRequestsProperty); }
            set { SafeSetValue(MemberRequestsProperty, value); }
        }

        /// <summary>
        /// Default constructor.
        /// </summary>
        public DatabaseAgency()
        {
        }

        /// <summary>
        /// Constructor for linking an Agency.
        /// </summary>
        /// <param name="baseAgency">Agency to link to.</param>
        public DatabaseAgency(LinkedDependencyObject baseAgency)
            : base(baseAgency)
        {
        }

        /// <summary>
        /// Constructor for linking with a specified BindingMode.
        /// </summary>
        /// <param name="baseAgency">Agency to link to.</param>
        /// <param name="bindingMode">BindingMode to use to link.</param>
        public DatabaseAgency(LinkedDependencyObject baseAgency, BindingMode bindingMode)
            : base(baseAgency, bindingMode)
        {
        }

        public override void LoadAllPropertyObjects()
        {
            #warning Not Implemented
        }

        public override void LoadPropertyObject(string propertyName)
        {
            #warning Not Implemented
        }
    }
}
